package com.yuandian.management.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuandian.api.management.entity.ConfMpAlarmPeriod;
import com.yuandian.bpm.common.core.util.R;
import com.yuandian.management.mapper.ConfMpAlarmPeriodMapper;
import com.yuandian.management.service.ConfMpAlarmPeriodService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 中台监控-告警周期配置表-Service实现
 * @author zfsn
 * @date 2023-4-19
 */
@Service
public class ConfMpAlarmPeriodServiceImpl extends ServiceImpl<ConfMpAlarmPeriodMapper, ConfMpAlarmPeriod>
		implements ConfMpAlarmPeriodService {

	/**
	 * 根据告警id集合删除告警周期配置
	 * @param alarmIdList 告警id集合
	 * @return 通用返回对象
	 */
	@Transactional(rollbackFor = Exception.class)
	@Override
	public R<Boolean> removeByAlarmIds(List<Integer> alarmIdList) {
		return R.ok(lambdaUpdate().in(CollUtil.isNotEmpty(alarmIdList), ConfMpAlarmPeriod::getAlarmId, alarmIdList).remove());
	}
}